package xs.szw.service.converter;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import xs.szw.service.model.vo.UserInfoVo;
import xs.szw.service.model.vo.UserVo;
import xs.szw.service.model.dto.user.UserDto;
import xs.szw.service.model.dto.user.UserUpdateDto;
import xs.szw.service.model.pojo.sys.User;

import java.util.List;

/**
 * @program: xs_oa
 * @description: 用户对象转换器
 * @author: Songzw
 * @create: 2025-02-10 14:02
 **/
@Mapper(componentModel = "spring")
public interface UserConverter {

    /**
     *  UserDto -> User
     * @param userDto
     * @return
     */
    User userDtoToUser(UserDto userDto);


    /**
     * User ->  UserVO
     * @param user
     * @return
     */
    @Mappings({
            @Mapping(source = "id",target = "userId")
    })
    UserVo userToUserVo(User user);

    /**
     * User -> UserInfoVo
     * @param user
     * @return
     */
    @Mappings({
            @Mapping(target = "userId", source = "id")
    })
    UserInfoVo userToUserInfoVo(User user);

    /**
     * List<User> -> List<UserVo>
     * @param userList
     * @return
     */
    @Mappings({
            @Mapping(target = "userId", source = "id")
    })
    List<UserVo> userListToUserVoList(List<User> userList);


    /**
     * UserUpdateDto -> User
     * @param userUpdateDto
     * @return
     */
    User userUpdateDtoToUser(UserUpdateDto userUpdateDto);
}
